package com.xishu.controller;

import com.xishu.annotation.valid.MethodValidator;
import com.xishu.entity.oplog.OrderOpLog;
import com.xishu.response.ResponseData;
import com.xishu.response.ResponseStatus;
import com.xishu.response.VerifyUtil;
import com.xishu.service.CommonService;
import com.xishu.util.Tools;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Api(description = "订单操作日志管理")
public class OrderOpLogController implements Tools {

    @ApiOperation(value = "查询订单操作日志")
    @PutMapping(value = ("/order/op/log"), produces = ("application/json;charset=UTF-8"))
    @MethodValidator(mustLogin = false, duplicationRequestCheck = true)
    public ResponseData search(@RequestBody OrderOpLog orderOpLog) throws Exception {
        VerifyUtil.verify(()->isNotEmpty(orderOpLog.getStartCreateTime()) && isNotEmpty(orderOpLog.getEndCreateTime()), ResponseStatus.PLEASE_SELECT_TIME);
        orderOpLog.setSortField(new String[]{"createTime"});
        orderOpLog.setSortType("DESC");
        ResponseData responseData = CommonService.getInstance().searchResponse(orderOpLog);
        return responseData;
    }

}
